package cn.calm.swing.osgi.mysql.blance.ui;

import java.awt.Component;

import javax.swing.DefaultCellEditor;
import javax.swing.JCheckBox;
import javax.swing.JTable;

public class JTableJCheckBoxEditor extends DefaultCellEditor {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JCheckBox box;

	public JTableJCheckBoxEditor(JCheckBox checkBox) {
		super(checkBox);
		box = checkBox;
	}

	public Component getTableCellEditorComponent(JTable table, Object value,
			boolean isSelected, int row, int column) {
		if (value instanceof Boolean) {
			box.setSelected(Boolean.valueOf(String.valueOf(value)));
			return box;
		}
		return box;
	}

	public Object getCellEditorValue() {
		return box.isSelected();
	}

}
